package com.huawei.hmsdemo10086;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;

import com.huawei.hms.push.HmsMessageService;

public class DemoHmsMessageService extends HmsMessageService {

    private static String TAG = "message_demo";
    @Override
    public void onNewToken(String token) {
        Log.i(TAG, "received refresh token:" + token);

        if (!TextUtils.isEmpty(token)) {
            refreshedTokenToServer(token);
        }
    }

    // If the version of the Push SDK you integrated is 5.0.4.302 or later, you also need to override the method.
    @Override
    public void onNewToken(String token, Bundle bundle) {
        Log.i(TAG, "have received refresh token " + token);

        if (!TextUtils.isEmpty(token)) {
            refreshedTokenToServer(token);
        }
    }

    private void refreshedTokenToServer(String token) {
        Log.i(TAG, "sending token to server. token:" + token);
    }


}
